/*
 * @Author: wuyue
 * @Date: 2023-03-06 16:06:56
 * @LastEditTime: 2023-03-21 18:06:15
 * @LastEditors: wuyue
 * @Descripttion: 
 * @version: 
 */
import dataFilter from '@/views/quality/equipmentManagement/constant/dataFilter'
import { equipmentStatusArr } from '@/views/quality/equipmentManagement/constant/dictionary'
import moment from 'moment';

const columns = [
    {
      title: '序号',
      width: 85,
      scopedSlots: { customRender: 'num' }
    },
    {
      title: '设备名称',
      ellipsis: true,
      dataIndex: 'mdName',
    },
    {
      title: '规格型号',
      ellipsis: true,
      dataIndex: 'specificationModel',
    },
    {
      title: '设备编码',
      ellipsis: true,
      dataIndex: 'mdCode'
    },
    {
      title: '设备状态',
      ellipsis: true,
      dataIndex: 'mdStatus',
      customRender: (text) => {
        return dataFilter(equipmentStatusArr, ['0', '1', '3']).find(item => item.value === text)?.label
      }
    },
    {
      title: '所在项目',
      ellipsis: true,
      dataIndex: 'projectName',
      customRender: (text) => text || '无'
    },
    {
      title: '下次检定日期',
      ellipsis: true,
      dataIndex: 'afterAppraisalDate',
      customRender: (text) => {
        return text&&moment(text).format('YYYY-MM-DD')
      }

    },
    {
      title: '操作',
      dataIndex: 'actions',
      width: '230px',
      fixed: 'right',
      scopedSlots: { customRender: 'actions' }
    }
  ]

const searchArr = (form) => {
  return [
    // 搜索框
    {
      name: '设备名称',
      type: 'a-input',
      disabled: true,
      value: form.mdInfoName,
    },
    {
      name: '规格型号',
      type: 'a-input',
      disabled: true,
      value: form.mdModelName
    },
    {
      name: '设备编号',
      type: 'input',
      value: 'mdCode'
    },
    {
      name: '所在单位',
      value: 'locationProjectId',
      type: 'select',
      data: form.unitArr
    },
    {
      name: '设备状态',
      type: 'select',
      value: 'mdStatus',
      data: dataFilter(equipmentStatusArr, ['0', '1', '3'])
    },
  ]
}
  export {
    columns,
    searchArr
  }